/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		VIN_EventSystem.h
//
//		Author			:		Ted Pereira
//
//		Purpose			:		Encapsulate all functionality in the Event System
//
//		Dates			:		Written( Feb 16, 2011 ) by Ted Pereira	LastUpdate( Feb 23, 2011  ) by Ted Pereira 
//	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef EVENT_SYSTEM_H_
#define EVENT_SYSTEM_H_

#include <list>
#include <map>

using std::multimap;
using std::pair;
using std::list;

#include "CEvent.h"
#include "IListener.h"
class VIN_EventSystem
{


private:

	multimap<EVENTID,IListener*> mClientDataBase;

	list<CEvent> mCurrentEvents;
	void DispatchEvent(CEvent* pEvent);
	bool AlreadyRegistered(EVENTID eventID, IListener* client);


	//Singleton Stuff
	VIN_EventSystem(){}
	~VIN_EventSystem(){}
	VIN_EventSystem( const VIN_EventSystem& copy);
	VIN_EventSystem& operator=( const VIN_EventSystem& assign);


public:
	static VIN_EventSystem* GetInstance();



	//Adds a client to database
	void ResgisterClient(EVENTID eventID, IListener* client);

	//Unresgisters a client for a specific event
	void UnregisterClient(EVENTID eventID, IListener* client);

	//Sends an event to be processed
	void SendEvent(EVENTID eventID, void* Data = NULL);

	//Processes all the events
	void ProcessEvents();

	//Clears all pending events
	void ClearEvents();

	//Unregisters all objects
	void ShutdownEventSystem();





};

#endif